/* 
 * \class findCoordinatesFromBrowser
 * \brief This class is used to determine the customer cordinates
 */

var coordinateFinder;
function findCoordinatesFromBrowser()
{

    this.userLat= null;
    this.userLong=null;
    this.locationAccuracy = null;
    this.coordintates = {};


 
    this.setIntoCoordinatesCoordinateFormat = function()
    {
        if (  this.userLat != null && this.userLong != null)
        {
            this.coordintates = {
                'user_loc_lat':this.userLat,
                "user_loc_long":this.userLong
                };
            return true;
        }
        else
        {
            return false;
        }
       
    }
  
    this.getCoordinates = function()
    {
        return {
            'user_loc_lat':this.userLat,
            "user_loc_long":this.userLong
            };

    }
  
    this.determineGeoLocationCoordinates = function ()
    {

    }
          
     
}

function useGeoLocator()
{
    coordinateFinder = new findCoordinatesFromBrowser();
    if (navigator.geolocation)
    {

        navigator.geolocation.getCurrentPosition(function (position)
        {
          
            coordinateFinder.userLat = position.coords.latitude;
            coordinateFinder.userLong = position.coords.longitude;
            coordinateFinder.locationAccuracy  = position.coords.accuracy;
            coordinateFinder.setIntoCoordinatesCoordinateFormat();
        //alert ('Longitude: ' + lon + ' , ' + 'Latitude: ' + lat + ' Accuracy: ' + acc);
        },function(){
            alert('No geolocation');
        },{
            enableHighAccuracy:true
        });

    }
}

